package com.asman.vr.dto

import androidx.annotation.MainThread
import androidx.lifecycle.LiveData
import com.asman.vr.network.*
import java.util.concurrent.Executor

class CollectionRepository(private val api: Api, private val networkExecutor: Executor) {

    @MainThread
    fun addSchemeCollect(schemeId: Long, vrType: Int) = liveData(
        api.addSchemeCollect(CollectionRequestBody.SchemeCollectBody(schemeId, vrType))
    )

    @MainThread
    fun deleteSchemeCollect(schemeId: Long, vrType: Int) = liveData(
        api.deleteSchemeCollect(CollectionRequestBody.SchemeCollectBody(schemeId, vrType))
    )

    fun deleteWorkCollect(id: Long, schemeId: Long) = liveData(
        api.deleteWorkCollect(CollectionRequestBody.WorkCollectBody(id, schemeId))
    )

    @MainThread
    fun addGoodsCollect(skuId: Long): LiveData<Resource<Int>> = liveData(
        api.addGoodsCollect(CollectionRequestBody.GoodsCollectBody(skuId))
    )

    @MainThread
    fun deleteGoodsCollect(skuId: Long) = liveDataNull(
        api.deleteGoodsCollect(CollectionRequestBody.GoodsCollectBody(skuId))
    )

    @MainThread
    fun deleteDesignerCollect(designerId: Long) = liveDataNull(
        api.deleteDesignerCollect(CollectionRequestBody.DesignerCollectBody(designerId))
    )

    @MainThread
    fun addDesignerCollect(designerId: Long) = liveDataNull(
        api.addDesignerCollect(CollectionRequestBody.DesignerCollectBody(designerId))
    )

    /**
     * @param type 1：我的换搭，2：收藏的案例
     */
    @MainThread
    fun getCollectionSchemeList(type: Int, pageNo: Int, pageSize: Int) = liveData(
        api.getCollectionSchemeList(type, pageNo, pageSize)
    )

    @MainThread
    fun getCollectionCountInfo() = liveData(api.getCollectionCountInfo())

    @MainThread
    fun getCollectionGoodsList(pageNo: Int, pageSize: Int) = liveData(
        api.getCollectionGoodsList(pageNo, pageSize)
    )

    @MainThread
    fun getCollectionDesignerShopList() = liveData(
        api.getCollectionDesignerShopList(2)
    )

    @MainThread
    fun getGoodsCollectStatus(skuId: Long) = liveData(
        api.getGoodsCollectStatus(skuId)
    )


}